package com.siemens.rebbitmq.consumer;

import java.nio.charset.StandardCharsets;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class MsgTestConsumer {

	/**
	 * 同步OSO客户信息至UM
	 * 
	 * @param message
	 */
	@RabbitListener(bindings = @QueueBinding(value = @Queue(value = "test-queue", durable = "true"), exchange = @Exchange(value = "test-exchange", durable = "true", type = "direct"), key = "test-key"))
	public void usrinfo(Message message) {
		String messages = new String(message.getBody(), StandardCharsets.UTF_8);
		try {
			String meg = JSON.parseObject(messages, String.class);
			System.out.println(meg);
		} catch (Exception e) {
			log.error("-----------videoRecordingCallback ERROR----------" + e.getMessage());
		}

	}
}
